<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div id="app">
    <h3>@keyup.enter → 监听键盘回车事件</h3>
    <!-- 通过"."指明指令的后缀，封装了不同的处理操作 -> 简化代码  -->
    <input @keyup.enter="fn" v-model="username" type="text">
</div>
<script src="./vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            username: ''
        },
        methods: {
            fn() {
                console.log("键盘回车的时候触发...", this.username)
            }
        }
    })
</script>
</body>
</html>